import { getUsers, saveUsers } from "../../server-data/users.js";

export default defineEventHandler(async (event) => {
  const body = await readBody(event);

  const id = String(Date.now());
  const newUser = { id, ...body };

  const users = await getUsers();
  users.push(newUser);
  await saveUsers(users);
  return newUser;
});
